//2009/09/09 08:10:58
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class BridgeSort
{
public:
    string sortedHand(string hand)
    {
        vector<pair<char, pair<int, string> > > v;
        for (int i=0; i<hand.size(); i+=2)
        {
            string s = hand.substr(i, 2);
            if (s[0]=='C' || s[0]=='D' || s[0]=='H' || s[0]=='S')
            {
                int temp;
                if (s[1]>='0' && s[1]<='9') temp = s[1]-'0';
                if (s[1]=='T') temp = 10;
                if (s[1]=='J') temp = 11;
                if (s[1]=='Q') temp = 12;
                if (s[1]=='K') temp = 13;
                if (s[1]=='A') temp = 14;
                v.push_back(make_pair(s[0], make_pair(temp, s)));
            }
        }
        sort(v.begin(), v.end());
        string s;
        for (int i=0; i<v.size(); i++)
            s += v[i].second.second;
        return s;
    }
};
